/*
 * FixedSizeRegisterSequentialFile_test.cpp
 *
 *  Created on: Oct 17, 2012
 *      Author: m
 */

#include <iostream>
#include "FixedSizeRegisterSequentialFile.h"

#define _REGISTER_SIZE 5
#define _READ_BUFFER_SIZE 15
#define _WRITE_BUFFER_SIZE 30

using namespace physical;

int main ( int argc, char* argv[] )
{
    std::string inFileName;
    std::string outFileName;
    byte registerBuffer[_REGISTER_SIZE];
    int i = 0;

    if ( argc != 3 )
    {
        std::cerr << "Argumentos invalidos. Uso: FSRSF_test input output." << std::endl;
        return 1;
    }


    inFileName = argv[1] ;
    outFileName = argv[2];

    FixedSizeRegisterSequentialFile inFile( _REGISTER_SIZE, inFileName.c_str(), std::ios_base::in, _READ_BUFFER_SIZE, _WRITE_BUFFER_SIZE );
    FixedSizeRegisterSequentialFile outFile( _REGISTER_SIZE, outFileName.c_str(), std::ios_base::out | std::ios_base::trunc, _READ_BUFFER_SIZE, _WRITE_BUFFER_SIZE );

    while ( !inFile.eof() )
    {
        inFile.readRegister(registerBuffer);
        outFile.writeRegister(registerBuffer);
        i++;
    }

    inFile.close();
    outFile.close();

    /*
    // TODO: revisar como agregar esto en otro test
    std::cout << "Registros Procesados: " << i << std::endl;
    std::cout << "Lecturas a disco: " << inFile.lecturas << std::endl;
    std::cout << "Escrituras a disco: " << outFile.escrituras << std::endl;
    */

    return 0;
}
